

package org.paul.hibernatetest;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import org.hibernate.Session;

/**
 *
 * @author paul
 */
public class ManyToOneDoubleSideTest {
   public static void main(String args[]){
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
      
        Event theEvent = new Event();
        theEvent.setTitle("hellowrodl");
        theEvent.setDate(new Date());
        
        Person person=new Person();
        person.setAge(20); 
        person.setFirstname("paul");
        person.setLastname("lee");
        Set<Event> events=new HashSet<Event>();
        events.add(theEvent);
        theEvent.setPerson(person);
        person.setEvents(events);
        session.save(person);

        session.getTransaction().commit();
   }
}
